<?php

if (!isset($_GET['id'])) $id = 0;
else $id = $_GET['id'];

if ($id>0) {
	$query = "SELECT * FROM recepti WHERE id=" . $id . ";";
	$result = myQuery($query);
	if (! ($row = mysql_fetch_array($result))) myDie("Kriticna greska sa id od recepta... ", "recepti.php");
	else $action = "edit&id=" . $row['id'];
}
else $action = "new";

print("<form method='POST' action=\"exec/recepti.php?action=" . $action . "\">");
?>

<div class='content' style='width: 400px'>
<span class='contentTitle'> Informacije o receptu </span>
<table class='tableResult' cellspacing='0' width='100%'>
	<tr>
		<th scope='row' class='spec'> Naziv </th>
		<td> 
			<input type='text' name='receptNaziv' style='width: 260px'
			<?php if ($id>0) print("value='" . $row['naziv'] . "'"); ?>	> 
		</td> 
	</tr>
			
	<tr>
		<th scope='row' class='spec'> Opis </th>
		<td> 
			<textarea name='receptOpis' rows='5' cols='30'><?php if ($id>0) print($row['opis']); ?></textarea> 
		</td> 
	</tr>
			
	<tr>
		<th scope='row' class='spec'> Reference </th>
		<td> 
			<textarea name='receptReference' rows='5' cols='30'><?php if ($id>0) print($row['reference']); ?></textarea> 
		</td>
	</tr>
			
	<tr>
		<th scope='row' class='spec' > Vlasnik </th>
		<td> <input type='text' name='receptVlasnik' style='width: 260px'
			<?php if ($id>0) print("value='" . $row['vlasnik'] . "'"); ?> > 
		</td> 
	</tr>
	
	<tr>
		<th scope='row' class='spec' colspan='2'><center><input type='submit' value='Spremi promjene'></center>  </th>
	</tr>
</table>
</div>

<?php print("</form>"); ?>